<%@ page import="java.sql.Connection" %>
<%@ page import="java.sql.PreparedStatement" %>
<%@ page import="java.sql.ResultSet" %>
<%@ page import="main.www.wonderfuldata.PreparedStatement.JDBCUtils" %>
<%@ page import="main.www.wonderfuldata.bean.User2" %>
<%@ page import="java.util.Scanner" %>
<%@ page import="main.www.wonderfuldata.com.StatementTest" %><%--
  Created by IntelliJ IDEA.
  User: gby0564
  Date: 2022/4/22
  Time: 10:39
  To change this template use File | Settings | File Templates.
--%>


<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>登陆界面</title>
</head>


<body>
<h1>login页面,登陆处理</h1>
    <%
        request.setCharacterEncoding("GBK");
        String name= request.getParameter("name");
        String password = request.getParameter("password");


        StatementTest st = new StatementTest();



        // SELECT user,password FROM user_table WHERE USER = '1' or ' AND PASSWORD = '='1' or '1' = '1';
        //String sql = "SELECT user,password FROM tudent01 WHERE user = '" + userName + "' AND password = '" + password+ "'";
        String sql = "SELECT name,idUser,password  FROM User WHERE name='"+name+"'";
        User2 user = st.get(sql, User2.class);

        if (user != null && password.equals(user.getPassword())) {
            System.out.println("登陆成功!"+user);
            response.sendRedirect("success.jsp?name="+name);


        } else {
            System.out.println("用户名或密码错误！");
            response.setHeader("Refresh","2;url=index.html");


        }



    %>


</body>
</html>
